<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="_patrimonio.xhtml">
	<ui:define name="corpo">

		<div id="conteudo">

			<h:form id="form">

				<h2>
					<h:outputText value="CADASTRAR ITEM" />
				</h2>
				<hr />			

				<p:messages id="msg" />
				
				<p:fieldset legend="Dados do Item">
					
				<h:outputLink value="javascript:void(0)" onclick="dlgNF.show();">
					<h:outputLabel value="Nota Fiscal: " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				</h:outputLink>
				<p:inputText id="nf" value="#{itemBean.item.nota.numero}" onclick="dlgNF.show();" 
					required="true" requiredMessage="Nº Não pode ser nulo" />&nbsp;&nbsp;&nbsp;
					
				<h:outputLink value="javascript:void(0)" onclick="dlgMaterial.show();">
					<h:outputLabel value="Descrição: " />&nbsp;&nbsp;&nbsp;
				</h:outputLink>
				<p:inputText id="material" value="#{itemBean.item.material.nome}" onclick="dlgMaterial.show();" 
					required="true" requiredMessage="Item Não pode ser nulo" style="width: 400px;" /><br /><br />
				
				<h:outputLabel value="Valor Unitário: " for="valor" />&nbsp;&nbsp;
				<p:inputText id="valor" value="#{itemBean.item.valor_unit}" required="true" requiredMessage="Valor Unitário não pode ser nulo">
					<f:convertNumber pattern="#0.00" />
				</p:inputText>&nbsp;
				<h:outputText value="Ex: 5000,90 Para Incluir Valores use este exemplo" style="color: #00BFFF; font-weight:bold;" /> <br /><br />
				
				<h:outputLabel value="Quantidade: " for="qtd" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<p:inputText id="qtd" value="#{itemBean.item.quantidade}" required="true" requiredMessage="Preencha o campo Quantidade" style="width: 50px;" />
				<br /><br />
								
				<h:outputLabel value="Marca: " for="marca" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<p:inputText id="marca" value="#{itemBean.item.marca}">
					<f:ajax event="change" />
				</p:inputText>	
				<br /><br />		

				<p:commandButton id="grava" value="GRAVAR" action="#{itemBean.grava}" ajax="false" image="ui-icon-disk">
					<f:ajax render="@all" />
				</p:commandButton>&nbsp;&nbsp;&nbsp;&nbsp;	

				<p:button id="reset" type="reset" value="LIMPAR"  />
							
				</p:fieldset>
								
				</h:form>
				
				<p:dialog header="Nota Fiscal" widgetVar="dlgNF" model="true"
				width="1000" showEffect="hide">
				<h:form id="form3">

					<p:outputPanel id="nfs">

						<p:dataTable id="listNf" value="#{notaFiscalBean.notas}" var="nota"
							paginator="true" rows="8"
							style="font-size: 12px" emptyMessage="Não Encontrado">


							<f:facet name="header">
								<h:outputText value="NOTAS FISCAIS CADASTRADAS" />
							</f:facet>

							<p:column sortBy="#{nota.numero}" filterBy="#{nota.numero}"
								filterMatchMode="contains" headerText="Número"
								style="width: 150px;">
								<h:commandLink value="#{nota.numero}" id="nf2">
									<f:setPropertyActionListener target="#{itemBean.item.nota}" value="#{nota}" />
								</h:commandLink>	
							</p:column>

							<p:column sortBy="#{nota.fornecedor.nome}"
								filterBy="#{nota.fornecedor.nome}" filterMatchMode="contains"
								headerText="Fornecedor" >
								<h:outputText value="#{nota.fornecedor.nome}" />
							</p:column>

							<p:column sortBy="#{nota.empenho.numero}"
								headerText="Empenho">
								<h:outputText value="#{nota.empenho.numero}" />
							</p:column>

						</p:dataTable>

					</p:outputPanel>
				</h:form>
			</p:dialog>
			
			<p:dialog header="Itens" widgetVar="dlgMaterial" model="true"
				width="700" showEffect="hide">
				<h:form id="form_item">

					<p:outputPanel id="itens">

						<p:dataTable id="listItem" value="#{materialBean.materiais}" var="material"
							paginator="true" rows="8" 
							style="font-size: 12px" emptyMessage="Não Encontrado">


							<f:facet name="header">
								<h:outputText value="MATERIAIS CADASTRADOS" />
							</f:facet>

							<p:column filterBy="#{material.nome}" filterMatchMode="contains"
									headerText="Nome">
									<h:commandLink value="#{material.nome}"	id="material">
										<f:setPropertyActionListener
											target="#{itemBean.item.material}" value="#{material}" />
									</h:commandLink>
								</p:column>

							<p:column sortBy="#{material.tipo}"
								filterBy="#{material.tipo}" filterMatchMode="contains"
								headerText="Tipo">
								<h:outputText value="#{material.tipo}" />
							</p:column>

						</p:dataTable>

					</p:outputPanel>
				</h:form>
			</p:dialog>
							
		</div>


	</ui:define>
</ui:composition>
</html>